home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / p4 / p4-1_2c.lha / p4-1.2c / lib / p4_debug.c < prev    next >
C/C++ Source or Header  |  1993-05-24  |  5KB  |  221 lines

  1. #include <stdio.h>
  2. #include <varargs.h>
  3. #include "p4.h"
  4. #include "p4_sys.h"
  5.  
  6. #if defined(p4_dprintfl)
  7. #undef p4_dprintfl
  8. #endif
  9.  
  10. int p4_get_dbg_level()
  11. {
  12.     return(debug_level);
  13. }
  14.  
  15. P4VOID p4_set_dbg_level(level)
  16. int level;
  17. {
  18.     debug_level = level;
  19. }
  20.  
  21. #if defined(DELTA)  ||  defined(NCUBE)
  22.  
  23. P4VOID p4_dprintf(fmt, a, b, c, d, e, f, g, h, i)
  24. {
  25.     printf("%s: ",whoami_p4);
  26.     printf(fmt,a,b,c,d,e,f,g,h,i);
  27.     fflush(stdout);
  28. }
  29.  
  30. #else
  31.  
  32. P4VOID p4_dprintf(fmt, va_alist)
  33. char *fmt;
  34. va_dcl
  35. {
  36.     va_list ap;
  37.  
  38.     printf("%s: ", whoami_p4);
  39.     va_start(ap);
  40. #ifdef VPRINTF
  41.     vprintf(fmt, ap);
  42. #else
  43.     _doprnt(fmt, ap, stdout);
  44. #endif
  45.     va_end(ap);
  46.     fflush(stdout);
  47. }
  48.  
  49. #endif
  50.  
  51. #if defined(DELTA)  ||  defined(NCUBE)
  52.  
  53. P4VOID p4_dprintfl(level, fmt, a, b, c, d, e, f, g, h, i)
  54. {
  55.     if (level > debug_level)
  56.         return;
  57.     printf("%s: ",whoami_p4);
  58.     printf(fmt,a,b,c,d,e,f,g,h,i);
  59.     fflush(stdout);
  60. }
  61.  
  62. #else
  63.  
  64. P4VOID p4_dprintfl(level, fmt, va_alist)
  65. int level;
  66. char *fmt;
  67. va_dcl
  68. {
  69.     va_list ap;
  70.  
  71.     if (level > debug_level)
  72.     return;
  73.     printf("%d: %s: ", level, whoami_p4);
  74.     va_start(ap);
  75. #ifdef VPRINTF
  76.     vprintf(fmt, ap);
  77. #else
  78.     _doprnt(fmt, ap, stdout);
  79. #endif
  80.     va_end(ap);
  81.     fflush(stdout);
  82. }
  83.  
  84. #endif 
  85.  
  86. P4VOID dump_global(level)
  87. int level;
  88. {
  89.     int i;
  90.     struct p4_global_data *g = p4_global;
  91.     struct proc_info *p;
  92.  
  93.     if (level > debug_level)
  94.     return;
  95.  
  96.     p4_dprintf("Dumping global data for process %d at %x\n", getpid(), g);
  97.  
  98.     for (i = 0, p = g->proctable; i < g->num_in_proctable; i++, p++)
  99.     {
  100.     p4_dprintf(" proctable entry %d: unix_id = %d host = %s\n",
  101.            i, p->unix_id, p->host_name);
  102.     p4_dprintf("   port=%d group_id=%d switch_port=%d\n",
  103.            p->port, p->group_id, p->switch_port);
  104.     }
  105.  
  106.     p4_dprintf("    listener_pid     = %d\n", g->listener_pid);
  107.     p4_dprintf("    listener_port    = %d\n", g->listener_port);
  108.     p4_dprintf("    local_slave_count= %d\n", g->local_slave_count);
  109.     p4_dprintf("    my_host_name     = %s\n", g->my_host_name);
  110.     p4_dprintf("    num_in_proctable = %d\n", g->num_in_proctable);
  111. }
  112.  
  113. P4VOID dump_local(level)
  114. int level;
  115. {
  116.     struct local_data *l = p4_local;
  117.     int i;
  118.  
  119.     if (level > debug_level)
  120.     return;
  121.  
  122.     p4_dprintf("Dumping local data for process %d at %x\n", getpid(), l);
  123.  
  124.     for (i = 0; i < p4_global->num_in_proctable; i++)
  125.     p4_dprintf("     %d: conntab[%d]  type:%s    port %d\n", getpid(), i,
  126.            print_conn_type(p4_local->conntab[i].type),
  127.            p4_local->conntab[i].port);
  128.  
  129.     p4_dprintf("    listener_fd = %d\n", l->listener_fd);
  130.     p4_dprintf("    my_id       = %d\n", l->my_id);
  131.     p4_dprintf("    am_bm       = %d\n", l->am_bm);
  132. }
  133.  
  134. char *print_conn_type(conn_type)
  135. int conn_type;
  136. {
  137.     static char val[20];
  138.  
  139.     switch (conn_type)
  140.     {
  141.       case CONN_ME:
  142.     return ("CONN_ME");
  143.       case CONN_REMOTE_SWITCH:
  144.     return ("CONN_REMOTE_SWITCH");
  145.       case CONN_REMOTE_NON_EST:
  146.     return ("CONN_REMOTE_NON_EST");
  147.       case CONN_REMOTE_EST:
  148.     return ("CONN_REMOTE_EST");
  149.       case CONN_SHMEM:
  150.     return ("CONN_SHMEM");
  151.       case CONN_CUBE:
  152.     return ("CONN_CUBE");
  153.       case CONN_REMOTE_DYING:
  154.     return ("CONN_REMOTE_DYING");
  155.       default:
  156.     sprintf(val, "invalid: %d  ", conn_type);
  157.     return (val);
  158.     }
  159. }
  160.  
  161.  
  162. P4VOID dump_listener(level)
  163. int level;
  164. {
  165.     struct listener_data *l = listener_info;
  166.  
  167.     if (level > debug_level)
  168.     return;
  169.  
  170.     p4_dprintf("Dumping listener data for process %d at %x\n", getpid(), l);
  171.     p4_dprintf("    listening_fd = %d\n", l->listening_fd);
  172. }
  173.  
  174. P4VOID dump_procgroup(procgroup, level)
  175. struct p4_procgroup *procgroup;
  176. int level;
  177. {
  178.     struct p4_procgroup_entry *pe;
  179.     int i;
  180.  
  181.     if (level > debug_level)
  182.     return;
  183.  
  184.     p4_dprintf("Procgroup:\n");
  185.     for (pe = procgroup->entries, i = 0;
  186.      i < procgroup->num_entries;
  187.      pe++, i++)
  188.     p4_dprintf("    entry %d: %s %d %s %s \n",
  189.            i,
  190.            pe->host_name,
  191.            pe->numslaves_in_group,
  192.            pe->slave_full_pathname,
  193.            pe->username);
  194. }
  195.  
  196. P4VOID dump_tmsg(tmsg)
  197. struct p4_msg *tmsg;
  198. {
  199.     p4_dprintf("type=%d, to=%d, from=%d, len=%d, ack_req=%x, msg=%s\n",
  200.            tmsg->type, tmsg->to, tmsg->from, tmsg->len, tmsg->ack_req,
  201.            &(tmsg->msg));
  202. }
  203.  
  204. P4VOID dump_conntab(level)
  205. int level;
  206. {
  207.     int i;
  208.  
  209.     if (level > debug_level)
  210.     return;
  211.  
  212.     for (i = 0; i < p4_global->num_in_proctable; i++)
  213.     {
  214.     p4_dprintf("   %d: conntab[%d] type=%s port=%d switch_port=%d\n",
  215.            getpid(), i,
  216.            print_conn_type(p4_local->conntab[i].type),
  217.            p4_local->conntab[i].port,
  218.            p4_local->conntab[i].switch_port);
  219.     }
  220. }
  221.